function JCSmartFilter(t,e,i){this.ajaxURL=t;this.form=null;this.timer=null;this.cacheKey="";this.cache=[];this.popups=[];this.viewMode=e;if(i&&i.SEF_SET_FILTER_URL){this.bindUrlToButton("set_filter",i.SEF_SET_FILTER_URL);this.sef=true}if(i&&i.SEF_DEL_FILTER_URL){this.bindUrlToButton("del_filter",i.SEF_DEL_FILTER_URL)}}JCSmartFilter.prototype.keyup=function(t){if(!!this.timer){clearTimeout(this.timer)}this.timer=setTimeout(BX.delegate((function(){this.reload(t)}),this),500)};JCSmartFilter.prototype.click=function(t){if(!!this.timer){clearTimeout(this.timer)}this.timer=setTimeout(BX.delegate((function(){this.reload(t)}),this),500)};JCSmartFilter.prototype.reload=function(t){if(this.cacheKey!==""){if(!!this.timer){clearTimeout(this.timer)}this.timer=setTimeout(BX.delegate((function(){this.reload(t)}),this),1e3);return}this.cacheKey="|";this.position=BX.pos(t,true);this.form=BX.findParent(t,{tag:"form"});if(this.form){var e=[];e[0]={name:"ajax",value:"y"};this.gatherInputsValues(e,BX.findChildren(this.form,{tag:new RegExp("^(input|select)$","i")},true));for(var i=0;i<e.length;i++)this.cacheKey+=e[i].name+":"+e[i].value+"|";if(this.cache[this.cacheKey]){this.curFilterinput=t;this.postHandler(this.cache[this.cacheKey],true)}else{if(this.sef){var r=BX("set_filter");r.disabled=true}this.curFilterinput=t;BX.ajax.loadJSON(this.ajaxURL,this.values2post(e),BX.delegate(this.postHandler,this))}}};JCSmartFilter.prototype.updateItem=function(t,e){if(e.PROPERTY_TYPE==="N"||e.PRICE){var i=window["trackBar"+t];if(!i&&e.ENCODED_ID)i=window["trackBar"+e.ENCODED_ID];if(i&&e.VALUES){if(e.VALUES.MIN){if(e.VALUES.MIN.FILTERED_VALUE)i.setMinFilteredValue(e.VALUES.MIN.FILTERED_VALUE);else i.setMinFilteredValue(e.VALUES.MIN.VALUE)}if(e.VALUES.MAX){if(e.VALUES.MAX.FILTERED_VALUE)i.setMaxFilteredValue(e.VALUES.MAX.FILTERED_VALUE);else i.setMaxFilteredValue(e.VALUES.MAX.VALUE)}}}else if(e.VALUES){for(var r in e.VALUES){if(e.VALUES.hasOwnProperty(r)){var s=e.VALUES[r];var l=BX(s.CONTROL_ID);if(!!l){var n=document.querySelector('[data-role="label_'+s.CONTROL_ID+'"]');if(s.DISABLED){BX.adjust(l,{props:{disabled:true}});if(n)BX.addClass(n,"disabled");else BX.addClass(l.parentNode,"disabled")}else{BX.adjust(l,{props:{disabled:false}});if(n)BX.removeClass(n,"disabled");else BX.removeClass(l.parentNode,"disabled")}if(s.hasOwnProperty("ELEMENT_COUNT")){n=document.querySelector('[data-role="count_'+s.CONTROL_ID+'"]');if(n)n.innerHTML=s.ELEMENT_COUNT}}}}}};JCSmartFilter.prototype.postHandler=function(t,e){var i,r,s;var l=BX("modef");var n=BX("modef_num");if(!!t&&!!t.ITEMS){for(var a in this.popups){if(this.popups.hasOwnProperty(a)){this.popups[a].destroy()}}this.popups=[];for(var o in t.ITEMS){if(t.ITEMS.hasOwnProperty(o)){this.updateItem(o,t.ITEMS[o])}}if(!!l&&!!n){n.innerHTML=t.ELEMENT_COUNT;i=BX.findChildren(l,{tag:"A"},true);if(t.FILTER_URL&&i){i[0].href=BX.util.htmlspecialcharsback(t.FILTER_URL)}if(t.FILTER_AJAX_URL&&t.COMPONENT_CONTAINER_ID){BX.unbindAll(i[0]);BX.bind(i[0],"click",(function(e){r=BX.util.htmlspecialcharsback(t.FILTER_AJAX_URL);BX.ajax.insertToNode(r,t.COMPONENT_CONTAINER_ID);return BX.PreventDefault(e)}))}if(t.INSTANT_RELOAD&&t.COMPONENT_CONTAINER_ID){r=BX.util.htmlspecialcharsback(t.FILTER_AJAX_URL);BX.ajax.insertToNode(r,t.COMPONENT_CONTAINER_ID)}else{if(l.style.display==="none"){l.style.display="inline-block"}if(this.viewMode==="VERTICAL"){s=BX.findChild(BX.findParent(this.curFilterinput,{class:"smart-filter-parameters-box"}),{class:"smart-filter-container-modef"},true,false);const t=BX.Dom.getPosition(l);if(t.x<0){BX.Dom.removeClass(l,"left");BX.Dom.addClass(l,"right")}BX.Dom.append(l,s)}if(t.SEF_SET_FILTER_URL){this.bindUrlToButton("set_filter",t.SEF_SET_FILTER_URL)}}}}if(this.sef){var c=BX("set_filter");c.disabled=false;c.focus()}if(!e&&this.cacheKey!==""){this.cache[this.cacheKey]=t}this.cacheKey=""};JCSmartFilter.prototype.bindUrlToButton=function(t,e){var i=BX(t);if(i){var r=function(t,e){return function(){return e(t)}};if(i.type=="submit")i.type="button";BX.bind(i,"click",r(e,(function(t){window.location.href=t;return false})))}};JCSmartFilter.prototype.gatherInputsValues=function(t,e){if(e){for(var i=0;i<e.length;i++){var r=e[i];if(r.disabled||!r.type)continue;switch(r.type.toLowerCase()){case"text":case"textarea":case"password":case"hidden":case"number":case"phone":case"email":case"select-one":if(r.value.length)t[t.length]={name:r.name,value:r.value};break;case"radio":case"checkbox":if(r.checked)t[t.length]={name:r.name,value:r.value};break;case"select-multiple":for(var s=0;s<r.options.length;s++){if(r.options[s].selected)t[t.length]={name:r.name,value:r.options[s].value}}break;default:break}}}};JCSmartFilter.prototype.values2post=function(t){var e=[];var i=e;var r=0;while(r<t.length){var s=t[r].name.indexOf("[");if(s==-1){i[t[r].name]=t[r].value;i=e;r++}else{var l=t[r].name.substring(0,s);var n=t[r].name.substring(s+1);if(!i[l])i[l]=[];var a=n.indexOf("]");if(a==-1){i=e;r++}else if(a==0){i=i[l];t[r].name=""+i.length}else{i=i[l];t[r].name=n.substring(0,a)+n.substring(a+1)}}}return e};JCSmartFilter.prototype.hideFilterProps=function(t){var e=t.parentNode,i=e.querySelector("[data-role='bx_filter_block']"),r=e.querySelector("[data-role='prop_angle']");if(BX.hasClass(e,"bx-active")){i.style.overflow="hidden";new BX.easing({duration:300,start:{opacity:100,height:i.offsetHeight},finish:{opacity:0,height:0},transition:BX.easing.transitions.quart,step:function(t){i.style.opacity=t.opacity/100;i.style.height=t.height+"px"},complete:function(){i.setAttribute("style","");BX.removeClass(e,"bx-active");BX.addClass(r,"smart-filter-angle-down");BX.removeClass(r,"smart-filter-angle-up")}}).animate()}else{i.style.display="block";i.style.opacity=0;i.style.height="auto";i.style.overflow="hidden";var s=i.offsetHeight;i.style.height=0;new BX.easing({duration:300,start:{opacity:0,height:0},finish:{opacity:100,height:s},transition:BX.easing.transitions.quart,step:function(t){i.style.opacity=t.opacity/100;i.style.height=t.height+"px"},complete:function(){i.style.overflow="";BX.addClass(e,"bx-active");BX.removeClass(r,"smart-filter-angle-down");BX.addClass(r,"smart-filter-angle-up")}}).animate()}};JCSmartFilter.prototype.showDropDownPopup=function(t,e){var i=t.querySelector('[data-role="dropdownContent"]');this.popups["smartFilterDropDown"+e]=BX.PopupWindowManager.create("smartFilterDropDown"+e,t,{autoHide:true,offsetLeft:0,offsetTop:3,overlay:false,draggable:{restrict:true},closeByEsc:true,content:BX.clone(i)});this.popups["smartFilterDropDown"+e].show()};JCSmartFilter.prototype.selectDropDownItem=function(t,e){this.keyup(BX(e));var i=BX.findParent(BX(e),{className:"smart-filter-input-group-dropdown"},false);var r=i.querySelector('[data-role="currentOption"]');r.innerHTML=t.innerHTML;BX.PopupWindowManager.getCurrentPopup().close()};BX.namespace("BX.Iblock.SmartFilter");BX.Iblock.SmartFilter=function(){var t=function(t){if(typeof t==="object"){this.leftSlider=BX(t.leftSlider);this.rightSlider=BX(t.rightSlider);this.tracker=BX(t.tracker);this.trackerWrap=BX(t.trackerWrap);this.minInput=BX(t.minInputId);this.maxInput=BX(t.maxInputId);this.minPrice=parseFloat(t.minPrice);this.maxPrice=parseFloat(t.maxPrice);this.curMinPrice=parseFloat(t.curMinPrice);this.curMaxPrice=parseFloat(t.curMaxPrice);this.fltMinPrice=t.fltMinPrice?parseFloat(t.fltMinPrice):parseFloat(t.curMinPrice);this.fltMaxPrice=t.fltMaxPrice?parseFloat(t.fltMaxPrice):parseFloat(t.curMaxPrice);this.precision=t.precision||0;this.priceDiff=this.maxPrice-this.minPrice;this.leftPercent=0;this.rightPercent=0;this.fltMinPercent=0;this.fltMaxPercent=0;this.colorUnavailableActive=BX(t.colorUnavailableActive);this.colorAvailableActive=BX(t.colorAvailableActive);this.colorAvailableInactive=BX(t.colorAvailableInactive);this.isTouch=false;this.init();if("ontouchstart"in document.documentElement){this.isTouch=true;BX.bind(this.leftSlider,"touchstart",BX.proxy((function(t){this.onMoveLeftSlider(t)}),this));BX.bind(this.rightSlider,"touchstart",BX.proxy((function(t){this.onMoveRightSlider(t)}),this))}else{BX.bind(this.leftSlider,"mousedown",BX.proxy((function(t){this.onMoveLeftSlider(t)}),this));BX.bind(this.rightSlider,"mousedown",BX.proxy((function(t){this.onMoveRightSlider(t)}),this))}BX.bind(this.minInput,"keyup",BX.proxy((function(t){this.onInputChange()}),this));BX.bind(this.maxInput,"keyup",BX.proxy((function(t){this.onInputChange()}),this))}};t.prototype.init=function(){var t;if(this.curMinPrice>this.minPrice){t=this.curMinPrice-this.minPrice;this.leftPercent=t*100/this.priceDiff;this.leftSlider.style.left=this.leftPercent+"%";this.colorUnavailableActive.style.left=this.leftPercent+"%"}this.setMinFilteredValue(this.fltMinPrice);if(this.curMaxPrice<this.maxPrice){t=this.maxPrice-this.curMaxPrice;this.rightPercent=t*100/this.priceDiff;this.rightSlider.style.right=this.rightPercent+"%";this.colorUnavailableActive.style.right=this.rightPercent+"%"}this.setMaxFilteredValue(this.fltMaxPrice)};t.prototype.setMinFilteredValue=function(t){this.fltMinPrice=parseFloat(t);if(this.fltMinPrice>=this.minPrice){var e=this.fltMinPrice-this.minPrice;this.fltMinPercent=e*100/this.priceDiff;if(this.leftPercent>this.fltMinPercent)this.colorAvailableActive.style.left=this.leftPercent+"%";else this.colorAvailableActive.style.left=this.fltMinPercent+"%";this.colorAvailableInactive.style.left=this.fltMinPercent+"%"}else{this.colorAvailableActive.style.left="0%";this.colorAvailableInactive.style.left="0%"}};t.prototype.setMaxFilteredValue=function(t){this.fltMaxPrice=parseFloat(t);if(this.fltMaxPrice<=this.maxPrice){var e=this.maxPrice-this.fltMaxPrice;this.fltMaxPercent=e*100/this.priceDiff;if(this.rightPercent>this.fltMaxPercent)this.colorAvailableActive.style.right=this.rightPercent+"%";else this.colorAvailableActive.style.right=this.fltMaxPercent+"%";this.colorAvailableInactive.style.right=this.fltMaxPercent+"%"}else{this.colorAvailableActive.style.right="0%";this.colorAvailableInactive.style.right="0%"}};t.prototype.getXCoord=function(t){var e=t.getBoundingClientRect();var i=document.body;var r=document.documentElement;var s=window.pageXOffset||r.scrollLeft||i.scrollLeft;var l=r.clientLeft||i.clientLeft||0;var n=e.left+s-l;return Math.round(n)};t.prototype.getPageX=function(t){t=t||window.event;var e=null;if(this.isTouch&&event.targetTouches[0]!=null){e=t.targetTouches[0].pageX}else if(t.pageX!=null){e=t.pageX}else if(t.clientX!=null){var i=document.documentElement;var r=document.body;e=t.clientX+(i.scrollLeft||r&&r.scrollLeft||0);e-=i.clientLeft||0}return e};t.prototype.recountMinPrice=function(){var t=this.priceDiff*this.leftPercent/100;t=(this.minPrice+t).toFixed(this.precision);if(t!=this.minPrice)this.minInput.value=t;else this.minInput.value="";smartFilter.keyup(this.minInput)};t.prototype.recountMaxPrice=function(){var t=this.priceDiff*this.rightPercent/100;t=(this.maxPrice-t).toFixed(this.precision);if(t!=this.maxPrice)this.maxInput.value=t;else this.maxInput.value="";smartFilter.keyup(this.maxInput)};t.prototype.onInputChange=function(){var t;if(this.minInput.value){var e=this.minInput.value;if(e<this.minPrice)e=this.minPrice;if(e>this.maxPrice)e=this.maxPrice;t=e-this.minPrice;this.leftPercent=t*100/this.priceDiff;this.makeLeftSliderMove(false)}if(this.maxInput.value){var i=this.maxInput.value;if(i<this.minPrice)i=this.minPrice;if(i>this.maxPrice)i=this.maxPrice;t=this.maxPrice-i;this.rightPercent=t*100/this.priceDiff;this.makeRightSliderMove(false)}};t.prototype.makeLeftSliderMove=function(t){t=t!==false;this.leftSlider.style.left=this.leftPercent+"%";this.colorUnavailableActive.style.left=this.leftPercent+"%";var e=false;if(this.leftPercent+this.rightPercent>=100){e=true;this.rightPercent=100-this.leftPercent;this.rightSlider.style.right=this.rightPercent+"%";this.colorUnavailableActive.style.right=this.rightPercent+"%"}if(this.leftPercent>=this.fltMinPercent&&this.leftPercent<=100-this.fltMaxPercent){this.colorAvailableActive.style.left=this.leftPercent+"%";if(e){this.colorAvailableActive.style.right=100-this.leftPercent+"%"}}else if(this.leftPercent<=this.fltMinPercent){this.colorAvailableActive.style.left=this.fltMinPercent+"%";if(e){this.colorAvailableActive.style.right=100-this.fltMinPercent+"%"}}else if(this.leftPercent>=this.fltMaxPercent){this.colorAvailableActive.style.left=100-this.fltMaxPercent+"%";if(e){this.colorAvailableActive.style.right=this.fltMaxPercent+"%"}}if(t){this.recountMinPrice();if(e)this.recountMaxPrice()}};t.prototype.countNewLeft=function(t){var e=this.getPageX(t);var i=this.getXCoord(this.trackerWrap);var r=this.trackerWrap.offsetWidth;var s=e-i;if(s<0)s=0;else if(s>r)s=r;return s};t.prototype.onMoveLeftSlider=function(t){if(!this.isTouch){this.leftSlider.ondragstart=function(){return false}}if(!this.isTouch){document.onmousemove=BX.proxy((function(t){this.leftPercent=this.countNewLeft(t)*100/this.trackerWrap.offsetWidth;this.makeLeftSliderMove()}),this);document.onmouseup=function(){document.onmousemove=document.onmouseup=null}}else{document.ontouchmove=BX.proxy((function(t){this.leftPercent=this.countNewLeft(t)*100/this.trackerWrap.offsetWidth;this.makeLeftSliderMove()}),this);document.ontouchend=function(){document.ontouchmove=document.touchend=null}}return false};t.prototype.makeRightSliderMove=function(t){t=t!==false;this.rightSlider.style.right=this.rightPercent+"%";this.colorUnavailableActive.style.right=this.rightPercent+"%";var e=false;if(this.leftPercent+this.rightPercent>=100){e=true;this.leftPercent=100-this.rightPercent;this.leftSlider.style.left=this.leftPercent+"%";this.colorUnavailableActive.style.left=this.leftPercent+"%"}if(100-this.rightPercent>=this.fltMinPercent&&this.rightPercent>=this.fltMaxPercent){this.colorAvailableActive.style.right=this.rightPercent+"%";if(e){this.colorAvailableActive.style.left=100-this.rightPercent+"%"}}else if(this.rightPercent<=this.fltMaxPercent){this.colorAvailableActive.style.right=this.fltMaxPercent+"%";if(e){this.colorAvailableActive.style.left=100-this.fltMaxPercent+"%"}}else if(100-this.rightPercent<=this.fltMinPercent){this.colorAvailableActive.style.right=100-this.fltMinPercent+"%";if(e){this.colorAvailableActive.style.left=this.fltMinPercent+"%"}}if(t){this.recountMaxPrice();if(e)this.recountMinPrice()}};t.prototype.onMoveRightSlider=function(t){if(!this.isTouch){this.rightSlider.ondragstart=function(){return false}}if(!this.isTouch){document.onmousemove=BX.proxy((function(t){this.rightPercent=100-this.countNewLeft(t)*100/this.trackerWrap.offsetWidth;this.makeRightSliderMove()}),this);document.onmouseup=function(){document.onmousemove=document.onmouseup=null}}else{document.ontouchmove=BX.proxy((function(t){this.rightPercent=100-this.countNewLeft(t)*100/this.trackerWrap.offsetWidth;this.makeRightSliderMove()}),this);document.ontouchend=function(){document.ontouchmove=document.ontouchend=null}}return false};return t}();
//# sourceMappingURL=script.map.js